<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>秒表</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="button" value="开始" @click="start"><br>
        {{num}}<br>
        <input type="button" value="暂停" @click="stop"></input>
    </div>
    <script>
        var vm = new Vue({
            el:"#app",
            data:{
                num:0,
            },
            methods:{
                start:function(){
                    vm.timer=setInterval(()=>{
                        vm.num++
                    },1000)
                },
                stop:function(){
                    clearInterval(vm.timer)
                }
            }
        })

    </script>
</body>
</html>